﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Modele
{
    public class Tablature
    {
        [XmlAttribute("NbCordes")]
        public int nbCordes = 6;

        [XmlAttribute("NbCases")]
        public int nbCases = 22; 

        [XmlElement(ElementName = "Accordage")]
        public List<Note> accordage = new List<Note>();

        /* représente toutes les  note possible */
        public List<Note> notePossible = new List<Note>();

        public Tablature()
        {
            nbCordes = 6;
            nbCases = 22;
            accordage.Clear();// on efface pour éviter la surchage lors de la désérialisation
            
           
        }



        public void  AccordageStandard(){
            accordage.Add(new Note(Note.NoteEn.E, Note.Alteration.No,4));
            accordage.Add(new Note(Note.NoteEn.A, Note.Alteration.No, 4));
            accordage.Add(new Note(Note.NoteEn.D, Note.Alteration.No, 5));
            accordage.Add(new Note(Note.NoteEn.G, Note.Alteration.No, 5));
            accordage.Add(new Note(Note.NoteEn.B, Note.Alteration.No, 5));
            accordage.Add(new Note(Note.NoteEn.E, Note.Alteration.No, 6));

        }

        public void UpdateNotePossible()
        {
            notePossible.Clear();
            Note[] noteCorde = new Note[nbCordes];

            // déclaration  des notes sur le manche 
            for (int cpt = 0; cpt <nbCordes; cpt++)
            {
                
                noteCorde[cpt] = accordage[cpt].Copy();

                for (int j = 0; j <= nbCases; j++)
                {
                    Note tmp = noteCorde[cpt].Copy();
                    tmp.tablatureInfos.numCorde = cpt;
                    tmp.tablatureInfos.numCase = j;                    
                    notePossible.Add(tmp );
            
                    noteCorde[cpt]++;
                    tmp = null;
                }
                noteCorde[cpt] = null; 
            }

           
        }



       /* public void changerAccordageCorde(int corde, Note.NoteEn accordage)
        {
            this.accordage.RemoveAt(corde);
            this.accordage.Insert(corde, accordage);
        }
        * */
    }
}
